echo "开始运行！"
if id -u bdc >/dev/null 2>&1; then
   #终止用户进程
   sudo pkill -u bdc
   sudo userdel bdc
   echo "bdc，用户删除成功！"
else
   echo "bdc，已被删除!"
fi
id bdc
username=bdc
group_name=wheel
if id -u  $username >/dev/null 2>&1; then
   echo "$username，用户存在跳过添加"
else
   #创建一个用户，其中-d和-m选项用来为登录名在/home目录下创建一个目录
   #-s 登录shell是， -g 用户主用户组
   sudo useradd -g $group_name  $username
   if [ $? -eq 0 ]; then
     echo "用户 $username 创建成功。"
   else
     echo "错误：创建用户 $username 失败。" 
     exit 1
   fi
   password=123123
   echo "$username:$password" | chpasswd 
   if [ $? -eq 0 ]; then
     echo "用户 $username 的密码设置成功。"
   else
     echo "错误：设置用户 $username 的密码失败。" 
     exit 1
   fi
fi
if [ -e /opt/module ]; then
    echo "/opt/module,已存在"
else
    sudo mkdir -p /opt/module
    echo "/opt/module,创建目录成功！"
fi
if [ -e /opt/softwar/software ]; then
    echo "/opt/softwar/software,已存在"
else
    sudo mkdir -p /opt/softwar/software
    echo "/opt/softwar/software,创建目录成功！"
fi
if [ -e /opt/softwar/shell ]; then
    echo "/opt/softwar/shell,已存在"
else
    sudo mkdir -p /opt/softwar/shell
    echo "/opt/softwar/shell,创建目录成功！"
fi
if [ -e /opt/softwar/config ]; then
    echo "/opt/softwar/config,已存在"
else
    sudo mkdir -p /opt/softwar/config
    echo "/opt/softwar/config,创建目录成功！"
fi
sudo chown -R wheel:bdc /opt/module
sudo chown -R wheel:bdc /opt/softwar
echo "运行结束！"